<!DOCTYPE html>
<html>

{include file='public/header'}
<style>
    .layui-form-label{
        width: 150px;
    }
</style>
<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="javascript:void(0)">首页</a>
            <a href="javascript:void(0)">充值面板管理</a>
            <a><cite>充值限制开关</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" id="reload" title="刷新">
            <i class="layui-icon" style="line-height:30px"><i class="iconfont">&#xe6aa;</i></i>
        </a>
    </div>
    <div class="x-body">
        <form class="layui-form" lay-filter="formAjax">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    开始收费集数限制<i class="layui-icon iconfont icon-lytishi1" id="start_charge_drama_series_limit"></i>
                </label>
                <div class="layui-input-block" style="display: flex;align-items: center;">
                    <input type="checkbox" lay-skin="switch" name="start_charge_drama_series_limit" lay-filter="start_charge_drama_series_limit" lay-text="ON|OFF">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    充值面板最低价限制<i class="layui-icon iconfont icon-lytishi1" id="bottom_price_limit"></i>
                </label>
                <div class="layui-input-block" style="display: flex;align-items: center;">
                    <input type="checkbox" lay-skin="switch" name="bottom_price_limit" lay-filter="bottom_price_limit" lay-text="ON|OFF">
                </div>
            </div>
            <input type="hidden" name="id">
        </form>
    </div>
    <script>
        let params = {
            editUrl: '/admin/money/rechargeLimitSwitch',
            detailUrl: '/admin/money/rechargeLimitSwitch?type=1',
        }
        form_ajax(params)
        layui.use(["form", "layer"], function () {
            var form = layui.form,
                layer = layui.layer;
            var id;
            Ajax(params.detailUrl,{},'post').then(result =>{
                result.data.start_charge_drama_series_limit = result.data.start_charge_drama_series_limit === 1 ? true : false
                result.data.bottom_price_limit = result.data.bottom_price_limit === 1 ? true : false
                form.val("formAjax",result.data);
                id = result.data.id;
            });
            form.on('switch(start_charge_drama_series_limit)', function(data){
                let value = data.elem.checked ? 1 : 2;
                Ajax('/admin/money/rechargeLimitSwitch',{id,start_charge_drama_series_limit:value})
            });
            form.on('switch(bottom_price_limit)', function(data){
                let value = data.elem.checked ? 1 : 2;
                Ajax('/admin/money/rechargeLimitSwitch',{id,bottom_price_limit:value})
            });
        });
        tips('#start_charge_drama_series_limit', '#start_charge_drama_series_limit', '如果开启新剧开始投放算起3天内，开始收费集数不能设置在20集之后')
        tips('#bottom_price_limit', '#bottom_price_limit', '如果开启新剧开始投放算起3天内，最低价不能低于5.9')
    </script>
</body>

</html>